import { IProfile } from '@/store/reducer/user';
import request from '@/utils/request';

export const sendCodeAPI = (mobile: string) => {
  return request({ url: '/v1_0/sms/codes/' + mobile });
};

export const loginAPI = (mobile: string, code: string) => {
  return request({
    url: '/v1_0/authorizations',
    method: 'post',
    data: {
      mobile,
      code,
    },
  });
};

export const getUserInfoAPI = () => {
  return request({ url: '/v1_0/user' });
};

export const getProfileAPI = () => {
  return request({ url: '/v1_0/user/profile' });
};
export const uploadPhotoAPI = (formData: FormData) => {
  return request({ url: '/v1_0/user/photo', method: 'patch', data: formData });
};

export const updateProfileAPI = (profile: Partial<IProfile>) => {
  return request({ url: '/v1_0/user/profile', method: 'patch', data: profile });
};
